package com.xh.demo.service.impl;

import com.xh.demo.client.InterceptorHttpApi;
import com.xh.demo.client.MultiHttpApi;
import com.xh.demo.client.SignHttpApi;
import com.xh.demo.client.ThreadPoolHttpApi;
import com.xh.demo.commons.model.Result;
import com.xh.demo.model.table.User;
import com.xh.demo.service.ClientUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wen
 * @since 2021-08-06
 */
@Service
public class ClientUserServiceImpl implements ClientUserService {

    @Autowired
    private MultiHttpApi multiHttpApi;
    @Autowired
    private InterceptorHttpApi interceptorHttpApi;
    @Autowired
    private SignHttpApi signHttpApi;
    @Autowired
    private ThreadPoolHttpApi threadPoolHttpApi;

    @Override
    public User getUserById(Long id) {
        Result<User> result = threadPoolHttpApi.getUser(id);
        return result.getData();
    }

    @Override
    public User getUserByIdV2(Long id) {
        Result<User> result = threadPoolHttpApi.getUserV2(id);
        return result.getData();
    }

    @Override
    public User saveUser(User user) {
        Result<User> result = threadPoolHttpApi.saveUser(user);
        return result.getData();
    }

    @Override
    public User getUserByIdTimestamp(Long id) {
        return interceptorHttpApi.getUserTimestamp(id).getData();
    }

    @Override
    public User getUserByIdSign(Long id) {
        return signHttpApi.getUserSign(id).getData();
    }

}
